<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>发表问题 编辑问题 公用</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../../res/layui/css/layui.css">
    <link rel="stylesheet" href="../../res/css/global.css">
    <script src="../../js/plugins/jquery.js"></script>
</head>
<body>

<div class="fly-header layui-bg-black">
    <div class="layui-container">
        <a class="fly-logo" href="../../html/index.html">
            <img src="../../res/images/logo.png" alt="layui">
        </a>

    </div>
</div>

<div class="layui-container fly-marginTop">
    <div class="fly-panel" pad20 style="padding-top: 5px;">
        <!--<div class="fly-none">没有权限</div>-->
        <div class="layui-form layui-form-pane">
            <div class="layui-tab layui-tab-brief" lay-filter="user">
                <ul class="layui-tab-title">
                    <li class="layui-this">发表新帖<!-- 编辑帖子 --></li>
                </ul>
                <div class="layui-form layui-tab-content" id="LAY_ucm" style="padding: 20px 0;">
                    <div class="layui-tab-item layui-show">

                            <div class="layui-row layui-col-space15 layui-form-item">
                                <div class="layui-col-md3">
                                    <label class="layui-form-label">所在专栏</label>
                                    <div class="layui-input-block">
                                        <select id="L_column" lay-verify="required" name="class" lay-filter="column">
                                            <option></option>
                                            <option value="提问">提问</option>
                                            <option value="分享">分享</option>
                                            <option value="讨论">讨论</option>
                                            <option value="建议">建议</option>
                                            <option value="公告">公告</option>
                                            <option value="动态">动态</option>
                                        </select>
                                    </div>
                                </div>
                                <div class="layui-col-md9">
                                    <label for="L_title" class="layui-form-label">标题</label>
                                    <div class="layui-input-block">
                                        <input type="text" id="L_title" name="title" required lay-verify="required"
                                               autocomplete="off" class="layui-input">
                                        <!-- <input type="hidden" name="id" value="{{d.edit.id}}"> -->
                                    </div>
                                </div>
                            </div>

                            <div class="layui-form-item layui-form-text">
                                <div class="layui-input-block">
                                    <textarea id="L_content" name="content" required lay-verify="required"
                                              placeholder="详细描述" class="layui-textarea fly-editor"
                                              style="height: 260px;"></textarea>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <div class="layui-inline">

                                </div>
                            </div>
                            <div class="layui-form-item">
                            </div>
                            <div class="layui-form-item">
                                <button onclick="pubInfo()" class="layui-btn">立即发布</button>
                            </div>

                    </div>
                </div>
            </div>
        </div>
    </div>
</div>


<script src="../../res/layui/layui.js"></script>
<script>
    layui.cache.page = 'jie';
    layui.cache.user = {
        username: '游客'
        , uid: -1
        , avatar: '../../res/images/avatar/00.jpg'
        , experience: 83
        , sex: '男'
    };
    layui.config({
        version: "3.0.0"
        , base: '../../res/mods/'
    }).extend({
        fly: 'index'
    }).use('fly');

    function pubInfo() {
        var Lcolumn = document.getElementById("L_column").value;
        var Ltitle = document.getElementById("L_title").value;
        var Lcontent = document.getElementById("L_content").value;
        $.ajax({
            type: "POST",
            contentType: "application/x-www-form-urlencoded",
            url: "http://localhost:8089/article/postArticle",
            data: {
                "title": Ltitle,
                "type": Lcolumn,
                "content": Lcontent,
            },
            xhrFields: {withCredentials: true},
            success: function (data) {
                window.top.alert("发表成功，快来查看一下吧");
                $(window.parent.document).find('#contentIframe').attr('src','../../html/detail_index.html');
            },
            //失败的回调函数
            error: function (data) {
                console.log(data.status)
            }
        });

    }
</script>

</body>
</html>